// Rental.cpp : Defines the entry point for the console application.
//

#include "stdafx.h"
#include "Rental.h"
#include "Rentals.h"
#include "Date.h"

#include <iostream>
#include <string>
#include <vector>

using namespace std;

Rental::Rental(string id, string car, string customer)
{
	rentalID = id;
	carName = car;
	customerName = customer;
}

Rental::Rental(string id, string car, string customer, string dateR, string dateD)
{
	rentalID = id;
	carName = car;
	customerName = customer;
	dateRented = dateR;
	dateDue = dateD;
}

string Rental::getRentalID() {return rentalID;}
string Rental::getCarName() {return carName;}
string Rental::getCustomerName() {return customerName;}
Date Rental::getDateRented() {return dateRented;}
Date Rental::getDateDue() {return dateDue;}
double Rental::getAmountDue() {return amountDue;}
double Rental::getPenaltyCharges() {return penaltyCharges;}
	
void Rental::setRentalID(string id) {rentalID = id;}
void Rental::setCarName(string car) {carName = car;}
void Rental::setCustomername(string customer) {customerName = customer;}
void Rental::setDateRented(string date) {dateRented.set(date);}
void Rental::setDateDue(string date) {dateDue.set(date);}
void Rental::setDateRented(int d1, int d2, int d3) {dateRented.set(d1, d2, d3);}
void Rental::setDateDue(int d1, int d2, int d3) {dateDue.set(d1, d2, d3);}
void Rental::setAmountDue(double amount) {amountDue = amount;}
void Rental::setPenaltyCharges(double amount) {penaltyCharges = amount;}

// // // //
void Rentals::createRental(string id, string car, string customer)
{
	Rental* r = new Rental(id, car, customer);
	rentalList.push_back(r);
}

void Rentals::createRental(string id, string car, string customer, string dateR, string dateD)
{
	Rental* r = new Rental(id, car, customer, dateR, dateD);
	rentalList.push_back(r);
}

void Rentals::addRental(Rental* r) {rentalList.push_back(r);}
void Rentals::deleteRental(string id)
{
	for(int i = 0; i < (int)rentalList.size(); i++)
	{
		if(rentalList[i]->getRentalID() == id) rentalList.erase(rentalList.begin()+i, rentalList.begin()+i+1);
	}
}

Rental* Rentals::getRental(string id)
{
	for(int i = 0; i < (int)rentalList.size(); i++)
	{
		if(rentalList[i]->getRentalID() == id) return rentalList[i];
	}
}
int Rentals::getNumRentals() {return (int)rentalList.size();}

int _tmain(int argc, _TCHAR* argv[])
{	
	/*int rentNum = 0;
	
	Rentals v;

	v.createRental(rentNum++, "car", "custard", "12-12-2007", "30-12-2007");

	cout << v.getRental(0)->getDateDue() << endl;

	Rental* r = new Rental(rentNum++, "car", "customer");
	Rental* a = new Rental(rentNum++, "van", "custard");
	Rental q(rentNum++, "bike", "Phil"); // disappears out of scope

	v.addRental(r);
	v.addRental(a);
	v.addRental(&q);

	cout << v.getRental(3)->getCarName() << endl;

	cout << v.getNumRentals() << endl;
	cout << v.getRental(1)->getCarName() << endl;

	v.deleteRental(0);

	cout << v.getNumRentals() << endl;

	cout << v.getRental(1)->getCarName() << endl;
	cout << v.getRental(1)->getRentalID() << endl;

	delete r;
	delete a;
	r = 0;
	a = 0;

	return 0;*/
}

